<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="my" uri="http://www.trkj.com/tr1702/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>考勤规则</title>
</head>
<body>
	<script type="text/javascript">
		var check_rule_state= function(value,row,index){
			var pic="";
			var state = row.KQRULE_KG;
			//alert("dfdf"+state);
			if(state==0){
				pic = "<input type='checkbox' disabled='disabled'>";
			}else if(state==1){
				pic="<input type='checkbox' checked disabled='disabled'>";
			}
			return pic;
		}
		$(function(){
			$("#lxl-bt-rule-reload").linkbutton({onClick:function(){
				$('#ly-rule-dg').datagrid('reload');
			}});
			//删除
			 $("#ly-bt-rule-delete").linkbutton({onClick:function(){
				 var dgd= $("#ly-rule-dg").datagrid("getSelected");
				if(!dgd){
						$.messager.alert('提示', '没有选中要删除的行！');
						return;
				}
				$.messager.confirm('确认', '真的要删除吗？', function(v){
					if(v){
					$("<form method = 'post'>").appendTo(document.body).form({
						url:'check_delete',
						onSubmit:function(params){
							params["kqruleId"] =dgd.KQRULE_ID;
							
						},success:function(v){
							v = eval("(" + v + ")");
							if(v.success){
								$.messager.alert('恭喜', '删除成功');
								$('#ly-rule-dg').datagrid('reload');
							}else{
								$.messager.alert('错误', '对不起，操作失败，原因：' + v.message);
							}
						}
					}).submit();
					}
				}); 
			}});
			//双击获取id到详情页面
			<my:g id="175">
			$('#ly-rule-dg').datagrid({
				onDblClickCell : function(index, field, value) {
					//获取值
					var selectedRow = $(this).datagrid('getSelected');
					var checkattruId = selectedRow.KQRULE_ID;
					
					$('#ly-rule-panel').panel({
							'href':'to_checkingdetails?kqruleId=' + checkattruId
					})
				}
			});
			</my:g>
			$("#ly-bt-rule-insert").linkbutton({onClick:function(){
				$('#ly-rule-panel').panel({
					'href':'to_checking-inset'
				})
			}});

		})
		
	</script>
	<div id="ly-rule-panel" class="easyui-panel" data-options="border:false,fit:true">
		<table  class="easyui-datagrid" width="100%" id="ly-rule-dg"
        data-options="
        fitColumns:true,
        border:false,
        singleSelect:true,
        autoRowHeight:true,
		method:'post',
		fit:true,
		url:'checkfindAll',
		pagination:true,
		pageSize:5,
		pageList:[5,10,15,20],
		toolbar:'#ly-bt-rule'
        ">   
    <thead>   
        <tr>   
            <th width="10%" data-options="field:'KQRULE_ID'" align="center">编号</th>   
            <th width="10%" data-options="field:'KQRULE_NAME'" align="center">名称</th>
			<th width="12%" data-options="field:'KQRULE_UP'" align="center">实出勤计算方式（上班）</th>
			<th width="12%" data-options="field:'KQRULE_DOWN'" align="center">实出勤计算方式(下班)</th>
			<th width="6%"  data-options="field:'KQRULE_KG',formatter:check_rule_state" align="center">忽略旷工</th>
			<th width="10%" data-options="field:'KQRULE_MARKS'" align="center">备注</th>
			<th width="14%" data-options="field:'KQRULE_STARTDATE',formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
						return;
				}" align="center">创建日期</th>
			<th width="10%" data-options="field:'KQRULE_PERSON'" align="center">创建者</th>
			<th width="15%" data-options="field:'KQRULE_UPDATE',formatter:function(value,row,index){
					if(value!=null){
						var date = new Date(value);
						return date.toLocaleString();
					}
						return;
				}" align="center">更新日期</th>
			
			</tr>   
    </thead>   
	</table>  
	
		<!-- 按钮 -->
		<div id="ly-bt-rule" style="padding: 5px; height:auto">
			<!-- 添加 -->
			<my:g id="43"><a id="ly-bt-rule-insert" class="easyui-linkbutton" data-options="iconCls:'icon-add',text:'新增'"></a></my:g>
			<my:g id="44"><a id="ly-bt-rule-delete" class="easyui-linkbutton" data-options="iconCls:'icon-no',text:'删除'"></a></my:g>
			<a id="lxl-bt-rule-reload" class="easyui-linkbutton" data-options="iconCls:'icon-reload'"></a>
			<a class="easyui-searchbox" data-options="label:'搜索', width:200,labelWidth:40,prompt:'请输入考勤名称',
			searcher:function(value, name){
				$('#ly-rule-dg').datagrid('load', 'is_to_checkbyname_like?kqruleName=' + value);
			}"></a>
		</div>
	</div>
</body>
</html>